<?php

namespace App\Providers;

use App\Models\Menu;
use Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
//        $menu = \Cache::remember('menu',120 ,function (){
//            return Menu::query()->where('parent_id',0)->with('sub')->oldest('sort')
//                ->get()->toArray();
//        });
        \Schema::defaultStringLength(191);
//        $menu = Menu::query()->where('parent_id',0)->with('sub')->oldest('sort')
//            ->get()->toArray();
//        view()->share('menu',$menu);
        Paginator::defaultView('pagination::default');
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        if($this->app->environment() !== 'production'){
            $this->app->register(IdeHelperServiceProvider::class);
        }
    }
}
